using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;


namespace YangtzeFilterTestSystem
{
    public partial class Pressure2FlowrateForm : Form
    {
        public Pressure2FlowrateForm()
        {
            InitializeComponent();

            BigNozzleRBtn.Checked = true;

            PressureTBox.Text = "0";
            FlowrateTBox.Text = "0";

        }

        private void CloseBtn_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void P2FBtn_Click(object sender, EventArgs e)
        {
            double NozzleDiameter;

            if (BigNozzleRBtn.Checked)
            {
                NozzleDiameter = 0.225;
            }
            else
            {
                NozzleDiameter = 0.150;
            }

            double Flowrate = 3669.1521 * NozzleDiameter * NozzleDiameter * Math.Sqrt(Convert.ToDouble(PressureTBox.Text));

            //NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;

            //nfi.NumberDecimalDigits = 0;

            FlowrateTBox.Text = Flowrate.ToString("F");

        }

        private void F2PBtn_Click(object sender, EventArgs e)
        {
            double NozzleDiameter;

            if (BigNozzleRBtn.Checked)
            {
                NozzleDiameter = 0.225;
            }
            else
            {
                NozzleDiameter = 0.150;
            }

            double delta_p = Convert.ToDouble(FlowrateTBox.Text) * Convert.ToDouble(FlowrateTBox.Text) / (13462677.1329 * Math.Pow(NozzleDiameter, 4));

            //NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;

            //nfi.NumberDecimalDigits = 0;

            PressureTBox.Text = delta_p.ToString("F");

        }
    }
}